import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 徐志荣
 * @date 2023/4/6 16:09
 */

//使用继承,是为了复用之前的代码
public class UdpDictServer  extends UdpEchoServer{
    private Map<String,String> dict = new HashMap<>();

    public UdpDictServer(int port) throws SocketException {
        super(port);

        dict.put("dog","小狗子");
        dict.put("cat","小猫咪");
        dict.put("fuck","wocao~");


    }
    @Override
    public String process(String request){
        return dict.getOrDefault(request,"没有查到该单词~");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer udpDictServer = new UdpDictServer(9090);
        udpDictServer.start();
    }
}
